<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欧锐激光中文网站后台管理</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/admin/js/cookie.js"></script>
    <style>
        .left-nav div ul h3{font-size: 18px;margin-left: 10px;font-weight: 700;padding: 10px 0;}
        .layui-this > .active{background: #d2d2d2}
    </style>
</head>
<body>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo"><a href="/admin">欧锐激光中文网站后台管理 v1.0</a></div>
    <div class="left_open">
        <i title="展开左侧栏" class="iconfont">&#xe699;</i>
    </div>


    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;"><!--{$Think.session.admin_name}--></a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a id="change">修改密码</a></dd>
                <dd><a href="/admin/login/logout">退出</a></dd>

            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">网站设置</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a  href="javascript:;" class="top-tab" data-url="/admin/config/index" data-id="9999">基本设置</a></dd>
                <dd><a  href="javascript:;" class="top-tab" data-url="/admin/config/setseo" data-id="9000">SEO设置</a></dd>
                <dd><a  href="javascript:;" class="top-tab" data-url="/admin/setup/pseo" data-id="9001">手机站设置</a></dd>
                <dd><a  href="javascript:;" class="top-tab" data-url="/admin/setup/social" data-id="9002">社交平台设置</a></dd>
                <dd><a  href="javascript:;" class="top-tab" data-url="/admin/setup/email" data-id="9003">邮件设置</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item to-index"><a href="javascript:;" class="top-tab" data-url="/admin/Backup/lists" data-id="9004">数据库管理</a></li>
        <li class="layui-nav-item to-index"><a id="deldir">清除缓存</a></li>
        <li class="layui-nav-item to-index"><a id="map">生成网站地图</a></li>
        <li class="layui-nav-item to-index"><a href="/" target="_blank">前台首页</a></li>
    </ul>
</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <div id="side-nav">
        <?php foreach($auth_menu as $val):?>
            <?php if(!empty($val['menu'])):?>
                <ul id="nav"> <h3><?php echo $val['name'];?></h3>
                    <?php foreach($val['menu'] as $menu):?>
                        <?php if(!empty($menu['sub'])):?>
                            <li>
                                <a href="javascript:;">
                                    <cite><?php echo $menu['name'];?></cite>
                                    <i class="iconfont nav_right">&#xe697;</i>
                                </a>
                                <ul class="sub-menu">
                                    <?php if(!empty($menu['sub'])):?>
                                        <?php foreach($menu['sub'] as $sub):?>
                                            <li class="layui-this">
                                                <a _href="<?php echo '/admin'.$sub['url'];?>" class="sub-box" id="<?php echo $sub['id'];?>">
                                                    <i class="iconfont"></i>
                                                    <cite><?php echo $sub['name'];?></cite>
                                                </a>
                                            </li>
                                        <?php endforeach;?>
                                    <?php endif;?>
                                </ul>
                            </li>
                        <?php endif;?>
                    <?php endforeach;?>
                </ul>
            <?php endif;?>
        <?php endforeach;?>
    </div>
</div>
<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="true">
        <ul class="layui-tab-title">
            <li class="home layui-this"><i class="layui-icon">&#xe68e;</i>首页</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <iframe src="<!--{:GetUrlRelativePath()}-->" frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg"></div>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<div class="footer">
    <div class="copyright">Copyright ©2017 x-admin v2.3 All Rights Reserved</div>
</div>
<!-- 底部结束 -->
<script>

    /*左侧菜单点击事件 存储菜单url 菜单Id 菜单名称*/
    $(".sub-box").click(function () {
        _setActiveCookie($(this).attr('_href'), $(this).find('cite').text(), $(this).attr('id'), 0);
    });

    layui.use('element', function(){
        var element = layui.element;


        $(".top-tab").click(function () {
            var lay_id = $(this).attr('data-id');
            var url = $(this).attr('data-url');
            var name = $(this).text();
            element.tabAdd('xbs_tab', {
                title: name
                ,content: '<iframe tab-id="'+lay_id+'" frameborder="0" src="'+url+'" scrolling="yes" class="x-iframe"></iframe>'
                ,id: lay_id
            });
            element.tabChange('xbs_tab', lay_id);
        });


        /*顶部tab 发生改变*/
        element.on('tab(xbs_tab)', function(data){
            return true;
            var　active_menu_url = $.cookie('active_menu_url');
            var　active_menu_id = parseInt($.cookie('active_menu_id'));
            var　active_menu_lay_id = parseInt(this.getAttribute('lay-id'));
            var　active_menu_name = $.cookie('active_menu_name');
            $.cookie('active_menu_lay_id', active_menu_lay_id);
            var menu_arr = {'url': active_menu_url, 'id':active_menu_id, 'name':active_menu_name,'lay_id':active_menu_lay_id};
            var active_menu = $.cookie('active_menu');
            if(!active_menu){
                $.cookie('active_menu', JSON.stringify([menu_arr]));
            } else {
                var active_menus = JSON.parse(active_menu);
                var mark = true;
                $.each(active_menus, function () {
                    /*如果当前tab 已存在 数据集中将不会推送到数据集中*/
                    if(parseInt(this.id) === active_menu_id){
                        mark = false;
                    }
                    /*设置当前tab 为 活动菜单*/
                    if(active_menu_lay_id === this.lay_id){
                        _setActiveCookie(this.url, this.name, this.id, this.lay_id);
                    }
                });
                if(mark === true){
                    active_menus.push(menu_arr);
                    $.cookie('active_menu', JSON.stringify(active_menus));
                }
            }
        });

        /*删除tab*/
        element.on('tabDelete(xbs_tab)', function(data){
            return true;
            var lay_id = parseInt($(this).parent().attr('lay-id'));
            var active_menu_lay_id = parseInt($.cookie('active_menu_lay_id'));
            var active_menu_id = parseInt($.cookie('active_menu_id'));
            var active_menu = JSON.parse($.cookie('active_menu'));

            $.each(active_menu, function (key, val) {
                if(val && parseInt(val.lay_id) === lay_id){
                    if(lay_id === active_menu_lay_id){
                        $(".sub-box").removeClass('active');
                        $("#"+active_menu_id).parent().parent().hide();
                        if(active_menu[key + 1]){
                            var active = active_menu[key + 1];
                            _setActiveCookie( active.url, active.name, active.id, active.lay_id);
                            $("#"+active.id).addClass('active');
                        }
                        else if(active_menu[key - 1]){
                            var active = active_menu[key - 1];
                            _setActiveCookie( active.url, active.name, active.id, active.lay_id);
                            $("#"+active.id).addClass('active');
                        } else {
                            _setActiveCookie('', '', 0, 0);
                        }
                    }
                     active_menu.splice(key, 1)
                }
            });
            $.cookie('active_menu', JSON.stringify(active_menu));
        });


        var active_menu = $.cookie('active_menu');
        if(active_menu){
            return true;
            active_menu = JSON.parse($.cookie('active_menu'));
            $.each(active_menu, function (key, val) {
                element.tabAdd('xbs_tab', {
                    title: val.name
                    ,content: '<iframe tab-id="'+val.lay_id+'" frameborder="0" src="'+val.url+'" scrolling="yes" class="x-iframe"></iframe>'
                    ,id: val.lay_id
                });
            });

        }




        var active_menu_lay_id = $.cookie('active_menu_lay_id');
        var active_menu_id = $.cookie('active_menu_id');
        if(!active_menu_id || !active_menu_lay_id){
            return true;
            _setActiveCookie('', '', 0, 0);
            $.cookie('active_menu', []);
           /* $(".sub-box").removeClass('active');
            $(".sub-menu").css('display', 'none');*/
        }
        if(active_menu_lay_id){
            return true;
            element.tabChange('xbs_tab', active_menu_lay_id);
        }
        if(active_menu_id){
           /* $("#"+active_menu_id).addClass('active');
            $("#"+active_menu_id).parent().parent().show();*/
        }
    });
    var _setActiveCookie = function (url, name, id, lay_id) {
        return true;
        $.cookie('active_menu_url', url ? url : '');
        $.cookie('active_menu_id', id ? id : 0);
        $.cookie('active_menu_name', name ? name : '');
        $.cookie('active_menu_lay_id', lay_id ? lay_id : 0);
    }


    //清楚缓存
    $('#deldir').click(function () {
        layer.confirm('确定删除缓存？', function(index){
            $.ajax({
                type: "get",
                dataType: "json",
                url: '/admin/index/clear_cache',
                success: function (res) {
                    var success = JSON.parse(res);
                    if(success.code===200){
                        layer.msg(success.msg);
                        layer.close(index);
                    }else {
                        layer.msg(success.msg)
                    }

                }
            });

        });
    })
    //地图
    $('#map').click(function () {
        layer.confirm('确定生成网站地图？', function(index){
            $.ajax({
                type: "get",
                dataType: "json",
                url: '/admin/index/ditu',
                success: function (res) {
                    var success = JSON.parse(res);
                    if(success.code===200){
                        layer.msg(success.msg);
                        layer.close(index);
                    }else {
                        layer.msg(success.msg)
                    }

                }
            });

        });
    })
    //修改密码
    $('#change').click(function () {
        layer.open({
            type: 2,
            area:  ["1000px","700px"],
            fix: false, //不固定
            maxmin: true,
            shade:0.4,
            title: '修改密码',
            content: '/admin/index/change',
            end: function(){
                window.location.href = "/admin/login/index";

            }
        });
    });
</script>
</body>
</html>